// TerminationContext.cs
//
// Copyright (c) 2007 Mike Strobel
//
// This source code is subject to the terms of the Microsoft Reciprocal License (Ms-RL).
// For details, see <http://www.opensource.org/licenses/ms-rl.html>.
//
// All other rights reserved.

using System;

using Supremacy.Entities;
using Supremacy.Game;

namespace Supremacy.Diplomacy
{
    [Serializable]
    public class TerminationContext
    {
        private readonly Agreement _agreement;
        private readonly int _terminatingPartyId;
        private readonly TerminationReason _reason;

        public TerminationContext(Agreement agreement, Civilization terminatingParty, TerminationReason reason)
        {
            if (agreement == null)
                throw new ArgumentNullException("agreement");
            _agreement = agreement;
            _terminatingPartyId = (terminatingParty != null) ? terminatingParty.CivID : Civilization.InvalidID;
            _reason = reason;
        }

        public Agreement Agreement
        {
            get { return _agreement; }
        }

        public Civilization TerminatingParty
        {
            get
            {
                return (_terminatingPartyId == Civilization.InvalidID)
                    ? null
                    : GameContext.Current.Civilizations[_terminatingPartyId];
            }
        }

        public TerminationReason Reason
        {
            get { return _reason; }
        }
    }

    public enum TerminationReason
    {
        CancelledBySender,
        CancelledByRecipient,
        Failed,
        Expired
    }
}
